package com.backend_pay.controller.user;

import com.backend_pay.service.IncomeDetailService;
import com.backend_pay.service.PayoutDetailService;
import com.backend_pay.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class LogoutController {
    @Autowired//多个类注入，需要分别注入
    UserService userService;
    @Autowired
    IncomeDetailService incomeDetailService;
    @Autowired
    PayoutDetailService payoutDetailService;

    //注销用户
    @DeleteMapping(value="/logoutUser/{id}")
    @ResponseBody
    public void logoutUser(@PathVariable("id") Integer id){
        //消除支出记录
        payoutDetailService.deletePayoutDetailById(id);
        //消除收入记录
        incomeDetailService.deleteIncomeDetailByUserId(id);
        //消除用户信息
        userService.deleteUserById(id);
    }
}
